﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace IntegradorMod
{
    public class Representante
    {
        private int id;
        private string nome;
        private string telefone;
        private string email;

        public int id_
        { 
            get { return id; } 
        }

        public string nome_
        {
            get { return nome; }
            set { this.nome = value; }
        }

        public string telefone_
        {
            get { return telefone; }
            set { this.telefone = value; }
        }

        public string email_
        {
            get { return email; }
            set { this.email = value; }
        }
        string strCon = @"Data Source=localhost\sqlexpress; Initial Catalog=Projeto1; Integrated Security=true";

        public string Inserir(Representante pRepresentante)
        {

            SqlConnection Con = new SqlConnection();
            Con.ConnectionString = strCon;
            try
            {
                Con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "INSERT INTO REPRESENTANTE (Nome, Telefone, Email) VALUES (@nome, @telefone, @email)";
                cmd.Connection = Con;
                cmd.Parameters.AddWithValue("@nome", pRepresentante.nome_);
                cmd.Parameters.AddWithValue("@telefone", pRepresentante.telefone_);
                cmd.Parameters.AddWithValue("@email", pRepresentante.email_);
                cmd.ExecuteNonQuery();
                Con.Close();


            }
            catch
            {

            }

            return "";
        }
    }
}
